package com.aaa.controller;


import com.aaa.entity.SubscriptionFans;
import com.aaa.service.impl.SubscriptionFansServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Bean
 * @since 2021-09-05
 */
@RestController
@Api(tags = "关注")
@CrossOrigin
@RequestMapping("/subscription-fans")
public class SubscriptionFansController {
    @Autowired
    SubscriptionFansServiceImpl  subscriptionFansServiceimpl;

    //关注
    @ApiOperation("添加关注")
    @RequestMapping(value = "add",method = RequestMethod.POST)
    public boolean add(@ApiParam("关注者的id") Integer uid, @ApiParam("关注者的昵称") String uname,@ApiParam("被关注者id") Integer id){
        return  subscriptionFansServiceimpl.add(uid,uname,id);
    }

    @ApiOperation("被关注列的通知内容")
    @RequestMapping(value = "seleatten",method = RequestMethod.POST)
    public List<Map<String,Object>> seleatten(@ApiParam("用户的id") Integer uid){
    return subscriptionFansServiceimpl.seleatten(uid);
    }

    @ApiOperation("取消关注")
    @RequestMapping(value = "deleatten",method = RequestMethod.POST)
    public boolean deleatten(@ApiParam("关注者") Integer uid,@ApiParam("被关注者") Integer id){
        HashMap<String, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("initiative_id",uid);
        objectObjectHashMap.put("passivity_id",id);
        return subscriptionFansServiceimpl.removeByMap(objectObjectHashMap);
    }
}
